package com.lzy.cloud.goods.service.GoodsServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzy.cloud.goods.dtos.CarSeriesDto;
import com.lzy.cloud.goods.entity.CarSeries;
import com.lzy.cloud.goods.mapper.CarSeriesMapperExt;
import com.lzy.cloud.goods.service.CarSeriesService;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by WIN7 on 2018/6/9.
 */
@Service
public class CarSeriesServiceImpl implements CarSeriesService{

    @Autowired
    CarSeriesMapperExt carSeriesMapperExt;

    @Override
    public Boolean add(CarSeriesDto carSeriesDto) {
        return carSeriesMapperExt.insertSelective(DozerUtils.map(carSeriesDto,CarSeries.class))>0;
    }

    @Override
    public Boolean delById(Long id) {
        return carSeriesMapperExt.deleteByPrimaryKey(id)>0;
    }

    @Override
    public Boolean update(CarSeriesDto carSeriesDto) {
        return carSeriesMapperExt.updateByPrimaryKeySelective(DozerUtils.map(carSeriesDto,CarSeries.class))>0;
    }

    @Override
    public PageInfo<CarSeriesDto> selectList(Pager pager, CarSeriesDto dto) {
        if (pager != null)
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        return new PageInfo<>(carSeriesMapperExt.selectList(dto));
    }

    @Override
    public CarSeriesDto selectById(Long id) {
        return DozerUtils.map(carSeriesMapperExt.selectByPrimaryKey(id),CarSeriesDto.class);
    }
}
